﻿' <summary>
' BeeWit IDE Entorno de desarrollo Visual para php.
' BeeWitPHP IDE es el único entorno de desarrollo para PHP 
' de tipo WYSIWYG (What You See Is What You Get). 
' ¡Ahora si!, aproveche la potencia del lenguaje PHP 
' y desarrolle más rápidamente gracias a la programación 
' intuitiva de BeeWit.
' Copyright © 2010 Dewins Murillo Garcia 
' EMAIL: dewinsmg@gmail.com
' EMAIL: dewins@beewitsoft.com
' Este Programa es Software Libre: usted puede redistribuirlo 
' y/o modificarlo bajo los términos de la Licencia Publica General 
' GNU como es publicada por la Fundacion de Software Libre; 
' en la 3ra versión de la licencia.
' Este programa es distribuido con la esperanza de que sea útil, 
' pero SIN GARANTÍA ALGUNA; sin siquiera la garantía implícita 
' de VALOR COMERCIAL o FORMADO PARA UN PROPÓSITO EN PARTICULAR. 
' Vea la Licencia Publica General GNU para mas detalles.
' Usted debe haber recibido una copia de la Licencia Publica General 
' GNU junto con este programa. Si no, vaya a http://www.beewitsoft.com
' o en http://code.google.com/p/ajax-beewit-php-ide/
' </summary>
' <remarks></remarks>

Public Class ctlNewOpenProject

    Public Sub New()

        ' Llamada necesaria para el Diseñador de Windows Forms.
        InitializeComponent()

        ' Agregue cualquier inicialización después de la llamada a InitializeComponent().
        Me.tabLocalFiles.Text = Object_Language.Lang_Text("Local Project")
        Me.TabFTPFiles.Text = Object_Language.Lang_Text("FTP Project")
        Me.btnCreateDir.Text = Object_Language.Lang_Text("Create Project Directory")
        Me.btnLoadProject.Text = Object_Language.Lang_Text("Load Project")

        DirList.Path = "c:\"
        Me.DriveList.Drive = "c:\"



    End Sub

    Private Sub DriveList_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DriveList.SelectedIndexChanged
        DirList.Path = Me.DriveList.Drive
    End Sub

    Private Sub btnCreateDir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Dim Name As String = InputBox(Object_Language.Lang_Text("Directory Name"), Object_Language.Lang_Text("Creating New Directory"))
        Project_Interfaz = New clsLocalFiles
        If Project_Interfaz.CreateDirectory(Me.DirList.Path & "\" & Name, True) Then
            Me.DirList.Refresh()
            Me.DirList.Path = Me.DirList.Path & "\" & Name
        End If
    End Sub

    Private Sub btnLoadProject_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnLoadProject.Click
        OpenProject()
    End Sub

    Public Sub OpenProject()
        Project_Interfaz = New clsLocalFiles
        Dim LastDirectory As String = Me.DirList.Path.Substring(Me.DirList.Path.LastIndexOf("\") + 1)
        Project_Path = Me.DirList.Path
        If Me.DirList.Text <> LastDirectory Then
            Project_Path = Me.DirList.Path & "\" & Me.DirList.Text
        End If
        Project_Type = "LOCAL"
        Project_Name = Me.DirList.Text
        Control_Console.AddMessages("Loading project " & Project_Name & "... ", ctlConsole.enumTypeMessages.isNOTIFICATION)
        Control_Explorer.LoadProject()
        If Project_Name <> "" Then
            Object_OpenedProjects.AddProject(Project_Name, Project_Path, Project_Type)
        End If
        Control_OpenedProjects.LoadOpenedProjects()
        General.Control_Menu.TSCompile.Enabled = True
        Control_Console.AddMessages("----> Loaded project " & Project_Name & "! ", ctlConsole.enumTypeMessages.isNOTIFICATION)
    End Sub

    Private Sub btnCreateDir_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCreateDir.Click
        CreateNewProject()
    End Sub

    Public Sub CreateNewProject()
        Project_Interfaz = New clsLocalFiles
        Dim DirectoryName As String = InputBox("Name", "New Directory")
        If DirectoryName = "" Then
            Exit Sub
        End If
        Dim LastDirectory As String = Me.DirList.Path.Substring(Me.DirList.Path.LastIndexOf("\") + 1)
        Project_Path = Me.DirList.Path
        If Me.DirList.Text <> LastDirectory Then
            Project_Path = Me.DirList.Path & "\" & Me.DirList.Text
        End If
        Project_Path &= "\" & DirectoryName
        If DirectoryName <> "" Then
            Control_Console.AddMessages("Creating project " & DirectoryName & "... ", ctlConsole.enumTypeMessages.isNOTIFICATION)
            General.Project_Interfaz.CreateDirectory(Project_Path, False)
            General.Project_Interfaz.CreateDirectory(Project_Path & "\logs", False)
            General.Project_Interfaz.CreateDirectory(Project_Path & "\ajax", False)
            General.Project_Interfaz.CreateDirectory(Project_Path & "\controls", False)
            General.Project_Interfaz.CreateDirectory(Project_Path & "\controls\html", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\ajax_control.cls", Project_Path & "\ajax\ajax_control.cls", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\ajax_prototype.js", Project_Path & "\ajax\ajax_prototype.js", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\ajax_system.cls", Project_Path & "\ajax\ajax_system.cls", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\index.php", Project_Path & "\index.php", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\index.cjx", Project_Path & "\index.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\index.cjx.view", Project_Path & "\index.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\boton.cjx", Project_Path & "\controls\html\boton.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\boton.cjx.view", Project_Path & "\controls\html\boton.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\cajatexto.cjx", Project_Path & "\controls\html\cajatexto.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\cajatexto.cjx.view", Project_Path & "\controls\html\cajatexto.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\combo.cjx", Project_Path & "\controls\html\combo.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\combo.cjx.view", Project_Path & "\controls\html\combo.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\menuhorizontal.cjx", Project_Path & "\controls\html\menuhorizontal.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\menuhorizontal.cjx.view", Project_Path & "\controls\html\menuhorizontal.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\menuvertical.cjx", Project_Path & "\controls\html\menuvertical.cjx", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\menuvertical.cjx.view", Project_Path & "\controls\html\menuvertical.cjx.view", False)

            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\boton.cjx.gif", Project_Path & "\controls\html\boton.cjx.gif", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\cajatexto.cjx.gif", Project_Path & "\controls\html\cajatexto.cjx.gif", False)
            General.Project_Interfaz.CopyFile(Application.StartupPath & "\resources\templates\combo.cjx.gif", Project_Path & "\controls\html\combo.cjx.gif", False)

            Control_Console.AddMessages("----> Created project " & DirectoryName & "! ", ctlConsole.enumTypeMessages.isNOTIFICATION)

        End If

        Project_Type = "LOCAL"
        Project_Name = DirectoryName

        Control_Console.AddMessages("Loading project " & DirectoryName & "... ", ctlConsole.enumTypeMessages.isNOTIFICATION)

        Control_Explorer.LoadProject()
        If Project_Name <> "" Then
            Object_OpenedProjects.AddProject(Project_Name, Project_Path, Project_Type)
        End If
        Control_OpenedProjects.LoadOpenedProjects()
        Me.DirList.Refresh()

        Control_Console.AddMessages("----> Loaded project " & DirectoryName & "! ", ctlConsole.enumTypeMessages.isNOTIFICATION)
    End Sub
End Class
